<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>China Fullfill</title>
<link href="/css/backstage.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/backstage.js"></script>
<link href="/css/blitzer/jquery-ui.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="/js/jquery-ui.js"></script>
<script>
	$(function(){
		$("#confirmDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide"
		});
		
		$("#editDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide",
			buttons:{
				"<{$lang.ok}>":function(){
					var data = $("#editpform").serializeArray();
					$.ajax({
						url:"/product/receiving/edit-product",
						type:"post",
						dataType:"json",
						async:false,
						data:data,
						success:function(json){
							if(json.ask){
								location.reload();
							}else{
								$("#confirmDialog").dialog("option","buttons",[
									{
										text:"<{$lang.ok}>",
										click:function(){
											$(this).dialog("close")
										}
									}
								]);
								$("#confirmDialog").html(json.message).dialog("open");
							}
						}
					});
				},
				"<{$lang.cancel}>":function(){
					$(this).dialog("close");
				}
			}
		});
		
		$("#content").height($(document).height());
		
		$(".confirm").click(function(){
			var obj = this;
			$("#confirmDialog").dialog("option","buttons",[
				{
					text:"YES",
					click:function(){
						$.ajax({
							url:"/product/receiving/confirm-product/productId/"+$(obj).attr("productid"),
							async:false,
							dataType:"json",
							success:function(json){
								if(json.ask){
									location.reload();
								}
							}
						});
						$(this).dialog("close")
					}
				},
				{
					text:"NO",
					click:function(){
						$(this).dialog("close")
					}
				}
			]);
			$("#confirmDialog").html("<{$lang.checked}><{$lang.product}><{$lang.msg}>,<{$lang.confirm}><{$lang.right}>?").dialog("open");
		});
		
		$(".edit").click(function(){
			$(".<{$lang.sku}>").html($(".<{$lang.sku}>"+$(this).attr("productid")).html());
			$("[name=productId]").val($(this).attr("productid"));			
			$("[name=category]").val($(".category"+$(this).attr("productid")).attr("tvalue"));
			$("[name=weight]").val($(".weight"+$(this).attr("productid")).attr("tvalue"));
			$("[name=declared]").val($(".declared"+$(this).attr("productid")).attr("tvalue"));
            $("[name=product_length]").val($(".product_length"+$(this).attr("productid")).attr("tvalue"));
            $("[name=product_width]").val($(".product_width"+$(this).attr("productid")).attr("tvalue"));
            $("[name=product_height]").val($(".product_height"+$(this).attr("productid")).attr("tvalue"));
			var pp_name = $(this).prev().val();
			if(pp_name){
				$('#packageBox').html(pp_name);
			}
			
			$("#editDialog").dialog("open");
		});

	});
</script>
<style>
	html,body{text-align:center;border:none;}
	#content{width:960px;text-align:left;position:relative;margin-left:auto;margin-right:auto;background:white;height:100%}
	.contentTop{height:50px;line-height:50px;width:100%;text-align:center;font-size:15px;font-weight:bold;}
	.contentBottom{height:50px;line-height:50px;width:100%;text-align:center}
	.list{width:880px;max-height:28cm;border-collapse:collapse;margin-left:auto;margin-right:auto;}
	.list th,.list td{border:1px solid black;text-align:center;}
	.width1{width:80px;text-align:right;}
	.width2{width:170px;}
	.width3{width:100px;}
	.width4{width:150px;}
	.center{text-align:center}
	.action{cursor:pointer;marin:2px}
	.editTable td{padding:5px;text-align:left;}
</style>
</head>
<body>
<div id="content">
	<div class="contentTop"><{$lang.first}><{$lang.receive}><{$lang.product}><{$lang.msg}><{$lang.input}><{$lang.confirm}>(ASN:<{$receiving.receiving_code}>)</div>
	<table class="list">
		<tr>
			<th><{$lang.sku}></th>
			<th><{$lang.product}><{$lang.name}></th>
			<th><{$lang.weight}></th>
			<th><{$lang.category}></th>
			<th><{$lang.package}><{$lang.type}></th>
			<th><{$lang.declar_price}></th>
            <th><{$lang.length}></th>
            <th><{$lang.width}></th>
            <th><{$lang.height}></th>
			<th><{$lang.operation}></th>
		</tr>
		<{foreach from=$items item=item}>
		<tr>
			<td class="<{$lang.sku}><{$item.product_id}>"><{$item.product.product_sku}></td>
			<td><{$item.product.product_sku}></td>
			<td class="weight<{$item.product_id}>" tvalue="<{$item.product.product_weight}>"><{$item.product.product_weight}></td>
			<td class="category<{$item.product_id}>" tvalue="<{$item.product.category.poc_id}>"><{$item.product.category.poc_value}></td>
			<td class="packect<{$item.product_id}>" tvalue="<{$item.product.product_packect_type}>">
			<{if $item.product.package.pp_name}>
				<{$item.product.package.pp_name}>
				
			<{else}>
				<{$lang.null}>
			<{/if}>
			</td>
			<td class="declared<{$item.product_id}>"  tvalue="<{$item.product.product_declared_value}>"><{$item.product.product_declared_value}></td>
            <td class="product_length<{$item.product_id}>" tvalue="<{$item.product.product_length}>"><{$item.product.product_length}></td>
            <td class="product_width<{$item.product_id}>" tvalue="<{$item.product.product_width}>"><{$item.product.product_width}></td>
            <td class="product_height<{$item.product_id}>" tvalue="<{$item.product.product_height}>"><{$item.product.product_height}></td>

            <td>
				<input type="hidden" name="hasPackage<{$key}>" value="<{$item.product.package.pp_name}>" />
				<img src="/images/icon/edit.gif" title="<{$lang.edit}>" class="action edit" productid="<{$item.product_id}>"/>
			</td>
		</tr>
		<{/foreach}>
	</table>
	<div class="contentBottom">
		
	</div>
</div>
<div id="confirmDialog" title="<{$lang.system}><{$lang.msg}>">
	
</div>
<div id="editDialog" title="<{$lang.edit}><{$lang.product}><{$lang.msg}>">
	<form id="editpform">
	<table class="editTable">
		<tr>
			<td><{$lang.product}><{$lang.sku}>:<input type="hidden" name="productId"/><input type="hidden" name="warehouseId" value="<{$receiving.warehouse_id}>"/></td>
			<td class="<{$lang.sku}>"></td>
		</tr>
		<tr>
			<td><{$lang.product}><{$lang.weight}>:</td><td><input type="text" name="weight" class="width4"/></td>
		</tr>
		<tr>
			<td><{$lang.product}><{$lang.category}>:</td><td><select name="category" class="width4">
			<{foreach from=$categorys item=category}>
				<option value="<{$category.poc_id}>"><{$category.poc_value}></option>
			<{/foreach}>
			</select></td>
		</tr>
		<tr>
			<td><{$lang.package}><{$lang.type}>:</td><td><span id="packageBox">
			<select name="packet" class="width4">
			<{foreach from=$packages item=package}>
				<option value="<{$package.pp_id}>"><{$package.pp_name}></option>
			<{/foreach}>
			</select></span></td>
		</tr>
        <tr><td><{$lang.declar_price}>:</td><td><input type="text" name="declared" class="width4"/></td></tr>
        <tr><td><{$lang.product}><{$lang.length}>:</td><td><input type="text" name="product_length" class="width4"/>cm</td></tr>
        <tr><td><{$lang.product}><{$lang.width}>:</td><td><input type="text" name="product_width" class="width4"/>cm</td></tr>
        <tr><td><{$lang.product}><{$lang.height}>:</td><td><input type="text" name="product_height" class="width4"/>cm</td></tr>
	</table>
	</form>
</div>
</body>
</html>